package cn.lzy.common.init;



import cn.lzy.common.constant.InitDataConstant;
import cn.lzy.common.redis.RedisServie;
import cn.lzy.head.service.Domain.HeadDO;
import cn.lzy.head.service.HeadService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class InitData implements InitializingBean {

    Logger logger = LoggerFactory.getLogger(InitData.class);

    @Autowired
    private HeadService headService;

    @Autowired
    private RedisServie redisServie;

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("开始加载初始化数据--lzy");
        initData();
        logger.info("初始化加载数据完成--lzy");
    }

    public void initData(){
        List<HeadDO> headFunction = headService.getHeadFunction();
        //将数据放到redis里面
        redisServie.setList(InitDataConstant.MIUI_HEADFUNCTION,headFunction);
    }
}
